﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.Core;
using System.Windows.Input;
using Agnes.Core;

namespace Agnes.TaskManager
{
    /// <summary>
    /// 启动文档库之前执行的命令
    /// </summary>
    public class TaskManagerLaunchCmd : AbstractCommand
    {
        /// <summary>
        /// Run
        /// </summary>
        public override void Run()
        { 
            AgnesServiceManager.LogServ.Info("初始化任务管理插件......");
            TaskManagerService.InitService();
            
            AgnesServiceManager.LogServ.Info("注册任务管理的WPF命令！");
            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenSummaryViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenSummaryViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenSummaryViewCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(NewSubTaskSummaryCmd.Requery,
                new ExecutedRoutedEventHandler(NewSubTaskSummaryCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(NewSubTaskSummaryCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(TaskLabelsEditorCmd.Requery,
                new ExecutedRoutedEventHandler(TaskLabelsEditorCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(TaskLabelsEditorCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(NewTaskSummaryCmd.Requery,
                new ExecutedRoutedEventHandler(NewTaskSummaryCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(NewTaskSummaryCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(DelTaskCmd.Requery,
                new ExecutedRoutedEventHandler(DelTaskCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(DelTaskCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(EditTaskCmd.Requery,
                new ExecutedRoutedEventHandler(EditTaskCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(EditTaskCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenTaskCalendarViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenTaskCalendarViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenTaskCalendarViewCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenTimeLineViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenTimeLineViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenTimeLineViewCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenDailyViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenDailyViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenDailyViewCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenMonthlyViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenMonthlyViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenMonthlyViewCmd.Instance.CanExcute)));

            AgnesCommandService.CommandBindings.Add(new CommandBinding(OpenWeeklyViewCmd.Requery,
                new ExecutedRoutedEventHandler(OpenWeeklyViewCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(OpenWeeklyViewCmd.Instance.CanExcute)));

            AgnesServiceManager.LogServ.Info("读取插件配置.......");

        }
    }
}
